package k1_exercise;

import java.util.Arrays;

public class Array_twoArrayItemSwap {
    /**
     * 两个数组元素交换 {1,2,3,4},{5,6,7,8}  ->  {5,6,7,8},{1,2,3,4}
     */
    public static void main(String[] args) {

        //初始化两个数组
        int[] nums_a = {1,2,3,4};
        int[] nums_b = {5,6,7,8};

        int tmp = 0;

        for (int i = 0; i < nums_a.length; i++) {
            tmp = nums_a[i];
            nums_a[i] = nums_b[i];
            nums_b[i] = tmp;
        }

        System.out.println(Arrays.toString(nums_a));
        System.out.println(Arrays.toString(nums_b));

    }
}
